package org.lex.jdbc.url;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import org.lex.jdbc.DriverLoader;
import org.lex.lang.AggregateException;

public class DriverConfig extends CommonObject {
	public DriverConfig initialize(String driverName, String className, String website) {
		String name = className.substring(className.indexOf('.') < 0 ? 0
				: className.indexOf('.') + 1);
		this.setName(name);
		this.setClassName(className);
		this.setWebsite(website);
		this.setDescription(className);
		return this;
	}

	private String className = "";
	private String website = "";
	private List<File> classpath = null;

	private boolean loaded = false;

	public void load() throws AggregateException {
		if (false == loaded) {
			new DriverLoader().loadDriver(this);
			loaded = true;
		}
	}

	public String getWebsite() {
		return website;
	}

	public void setWebsite(String website) {
		this.website = website;
	}

	public List<File> getClasspath() {
		if (null == classpath) {
			classpath = new ArrayList<File>();
		}
		return classpath;
	}

	public void setClasspath(List<File> classpath) {
		this.classpath = classpath;
	}

	public String getClassName() {
		return className;
	}

	public void setClassName(String className) {
		this.className = className;
	}
}
